package com.ijiuchuang.jc_localization.tools.utils;

import android.graphics.PointF;

/**
 * Created by Administrator on 2016/4/21
 */
public class PositionCount {

    private PointF light5 = new PointF(9.0f, 5.55f);		//light5
    private PointF light4 = new PointF(7.5f, 12.15f);		//light4
    private PointF light3 = new PointF(7.6f, 11.80f);		//light3
    private PointF light2 = new PointF(18.0f, 8.00f);		//light2
    private PointF light1 = new PointF(18.0f, 8.00f);		//light1

    public final int POS1 = 1;
    public final int POS2 = 2;
    public final int POS3 = 3;
    public final int POS5 = 5;

    private static double rssi1;                  //一号点的 rssi
    private static double rssi2;                  //二号点的 rssi
    private static double rssi3;                  //三号点的 rssi
    private static double rssi5;                  //五号点的 rssi

    private double rssi0;                  // 0号点的 rssi

    private int position;

    public PositionCount(int rssi1, int rssi2, int rssi3, int rssi5) {
        PositionCount.rssi1 = rssi1;
        PositionCount.rssi2 = rssi2;
        PositionCount.rssi3 = rssi3;
        PositionCount.rssi5 = rssi5;
    }

    public int getPosition(int position, double rssi0) {
        this.position = position;
        switch (position) {
            case POS1:
                rssi1 = rssi0;
                break;
            case POS2:
                rssi2 = rssi0;
                break;
            case POS3:
                rssi3 = rssi0;
                break;
            case POS5:
                rssi5 = rssi0;
                break;
        }

        if (rssi2 > rssi3 && rssi2 > rssi5) {
            return POS2;
        } else if (rssi3 > rssi2 && rssi3 > rssi5) {
            return POS3;
        } else {
            return POS5;
        }
    }
}
